#include<stdio.h>

void find(int *arr,int target,int left,int right)
{
    int mid=0;
  while(left<=right)
  {
    mid=(left+right)/2;
 
    if(arr[mid]==target)//找到
    {
        printf("恭喜查找成功\n");
        return ;
    }
    else if(arr[mid]<target)//大于中间值
    {
       left=mid+1;
    }
    else//小于中间值
    {
       right=mid-1;
    }
  }
 
  if(left>right)printf("查找失败\n");//没找到
 
  return ;
}

int main(int argc, char const *argv[])
{
    int arr[10]={1,3,5,7,9,10,11,12,15,20};
    find(arr,9,0,9);
    return 0;
}
